<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>党建网</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../assets/css/amazeui.css" />
<link rel="stylesheet" href="../../assets/css/admin.css">
<link rel="stylesheet" href="../../css/amazeui.datetimepicker.css" />
<link href="../../css/video-js.min.css" rel="stylesheet">
<script src="../../js/video.min.js"></script>

</head>
<body>
	<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

	<header class="am-topbar amt-header"> </header>

	<div class="am-cf">
		<!-- sidebar start -->
		<div class="admin-sidebar am-offcanvas" id="admin-offcanvas"></div>
		<!-- sidebar end -->

		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				<div class="am-cf am-padding" style="margin-left: 2%">
					<div class="am-fl am-cf">
						<strong class="am-text-primary am-text-lg" style="color: #BD2D30">发布视频</strong>
					</div>
				</div>

				<form class="am-form am-form-horizontal">
					<div class="am-form-group">
						<label for="title_ipt" class="am-u-sm-1 am-form-label">主栏目</label>
						<div class="am-u-sm-2 am-u-end col-end" style="padding-top: 10px">
							<select data-am-selected id="mcol" >
								<option value='000'>点击选择...</option>
							</select>
						</div>
					</div>

					<div class="am-form-group">
						<label for="title_ipt" class="am-u-sm-1 am-form-label">子栏目</label>
						<div class="am-u-sm-2 am-u-end col-end" style="padding-top: 10px">
							<select data-am-selected id="scol">

							</select>
						</div>
					</div>

					<div class="am-form-group">
						<label for="author_ipt" class="am-u-sm-1 am-form-label">标题</label>
						<div class="am-u-sm-4 am-u-end col-end" style="padding-top: 10px">
							<input type="text" id="title_ipt" placeholder="请输入标题">
						</div>
					</div>

					<div class="am-form-group">
						<label for="editor" class="am-u-sm-1 am-form-label">介绍</label>
						<div class="am-u-sm-4  " style="padding-top: 10px">
							<!-- <script id="editor" type="text/plain" style="width:100%;height:500px;"></script> -->
							
								<textarea id="video_introduction" placeholder="请输入介绍" rows="12"></textarea>
								
								<div class="am-u-sm-4 am-u-md-4 am-u-end col-end">
									<div class="img-head">
										<div style="display: none">
											<p>
												<!-- 上传视频，accept改成video -->
												<input type="file" id="head_file_ipt" name="video"
													onChange="ajaxFileUpload();" accept="video/mp4" />
											</p>
										</div>
									</div>
								</div>
							
						</div>
						<div class="am-u-sm-4 am-u-end col-end" id="vvv" style="padding-top: 10px">
						
		</div>
					</div>
				</form>

				<div class="am-g" style="margin-top: 10px">
					<div class="am-u-sm-10 am-u-sm-centered" style="text-align: left">
					<button type="button" class="am-btn am-btn-primary" id="head_btn" style="background: #BD2D30; border-color: #BD2D30;">上传视频</button>
						<button type="button" class="am-btn am-btn-primary" id="pub_btn"
							style="background: #BD2D30; margin-left: 1% ;border-color: #BD2D30">发布</button>
						<button type="button" class="am-btn am-btn-primary" id=""
							style="background: #BD2D30; border-color: #BD2D30; margin-left: 1%">取消</button>
					</div>
				</div>

			</div>


		</div>
		<!-- content end -->

	</div>

	<a href="#" class="am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"> <span
		class="am-icon-btn am-icon-th-list"></span>
	</a>


	<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

	<!--[if (gte IE 9)|!(IE)]><!-->
	<script src="../../assets/js/jquery.min.js"></script>
	<!--<![endif]-->
	<script src="../../assets/js/amazeui.min.js"></script>
	<script src="../../js/left-nav.js"></script>
	<script src="../../js/header.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/ueditor.all.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../js/amazeui.datetimepicker.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../../js/bootstrap-datetimepicker.zh-CN.js"></script>
	<script src="../../js/ajaxfileupload.js"></script>
	<script src="../../js/index.js"></script>
	<script src="../../js/global.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#collapse-nav-1").addClass("am-in");

			searchMcol();
			searchScol();

		})
		//实例化编辑器
		//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
		//var ue = UE.getEditor('editor');

<!-- 上传视频，返回的JSON中路径是url，不是userHeadUrl，start -->
		
		/* 上传头像按钮点击事件 */
		$("#head_btn").on("click", function() {
			$("#head_file_ipt").trigger("click");
		})
		/* 文件上传 */
		var userHeadUrl;
		function ajaxFileUpload() {
			$.ajaxFileUpload({
				url : '/partyBuilding/files/video', //用于文件上传的服务器端请求地址
				secureuri : false, //是否需要安全协议，一般设置为false
				fileElementId : 'head_file_ipt', //文件上传域的ID
				dataType : 'json', //返回值类型 一般设置为json
				success : function(data) { //服务器成功响应处理函数
					ALERT(JSON.stringify(data));
					if (data.code == 200) {
						userHeadUrl = data.url;
						alertModal("提示", "上传成功", function() {//$("#adminHead").html('<img class="am-circle am-img-thumbnail img_1" src="'+ userHeadUrl +'" />');
							//$("#adminHead").attr('src', userHeadUrl);
						});
						$("#vvv").html("");
						$("#vvv").append('<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="none" style="width:640px;height:264px;" data-setup="{}">'+
									 '<source id="url" src="'+userHeadUrl+'" type="video/mp4" />'+
									'<track kind="captions" src="demo.captions.vtt" srclang="en" abel="English"></track>'+
									
									'<track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track>'+
								'</video>')
					}
				},
				error : function(data, status, e) { //服务器响应失败处理函数
					handleAjaxError();
				}
			});
		}
		
		<!-- 上传视频，end -->
		
		$("#pub_btn").click(function() {
			var content = {};

			//主栏目
			var mcol = $("#mcol").val();
			if (mcol == 000) {
				alertModal("提示", "请选择主栏目");
				return false;
			}
			content["fkMcol"] = mcol;
			//子栏目
			var scol = $("#scol").val();
			if (scol == 000) {
				alertModal("提示", "请选择子栏目");
				return false;
			}
			content["fkScol"] = scol;

			// 标题
			var vedioTitle = $("#title_ipt").val();
			if (vedioTitle == "") {
				alertModal("提示", "标题未填写");
				return false;
			}
			content["vedioTitle"] = vedioTitle;

			var introduction = $("#video_introduction").val();
			content["vedioIntro"] = introduction;
			// 路径
			if (userHeadUrl == "") { // 若公告链接未填写，需检查正文内容是否为空
				alertModal("提示", "视频未上传");
				return false;
			} else {
				content["vedioUrl"] = userHeadUrl;
				saveNews(content);
			}
			

		});

		/* 保存公告 */
		function saveNews(content) {
			$.ajax({
				type : "POST",
				url : "/partyBuilding/vedio",
				data : encrypt(content),
				contentType : "application/json",
				dataType : "json",
				success : function(data) {
					ALERT(JSON.stringify(data));
					if (data.code == "200") {
						alertModal("提示", "发布成功", function() {
						});
					} else {
						alertModal("警告", data.msg);
					}
				},
				error : function() {
					alertModal("警告", "服务器开小差了");
				}
			});
		}
		
	</script>
</body>
</html>
